/*
 *  visrep.h
 *  BioBreak
 *
 *  Created by terry franguiadakis on 2/19/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#pragma once
#include "bbmath.h"
#include "texture.h"

// -----------------------------------------------------------------------------

class VisibleItem 
{
public:
    VisibleItem() {
    }
    virtual bool Hit(const Vector2f& i_pos) = 0;
    virtual void Render() = 0;
    virtual void RenderNoTransform() {} 
    
    void SetPos(float i_x, float i_y) {
        m_transform.SetPos(Vector2f(i_x, i_y));
    }
    void SetPos(const Vector2f& i_pos) {
        m_transform.SetPos(i_pos);
    }
    
    float Dist(const Vector2f& i_pos) {
        return ::Dist(m_transform.GetPos(), i_pos);
    }
protected:
    
    Transform2D m_transform;    
};

// -----------------------------------------------------------------------------

class TestItemCircle : public VisibleItem 
{
public:
    TestItemCircle(const Vector2f& i_pos, float i_radius=1.0f);
    
    // overrides testitem
    virtual bool Hit(const Vector2f& i_pos);
    virtual void Render();
    virtual void  RenderNoTransform();
    
    float GetRadius() {
        return m_radius;
    }
    void SetRadius(float i_radius) {
        m_radius = i_radius;
    }
    
private:
    
    float m_radius;
    bool  m_isHit;
};

// -----------------------------------------------------------------------------

class TestItemPoint : public VisibleItem
{
public:
    TestItemPoint(const Vector2f& pos, float i_size): m_size(i_size){ SetPos(pos);}

    TestItemPoint():m_size(1.0) { }
    
    // override testitem
    virtual bool Hit(const Vector2f& i_pos) {
        return false;}
    // override testitem
    virtual void Render();
protected:
    float m_size;
    
};

// -----------------------------------------------------------------------------

class TestItemQuad : public VisibleItem
{
public:
    TestItemQuad(const Vector2f& i_pos, float i_size);
    
    void SetSize(float i_size) {
                        m_size = i_size;
                        m_transform.SetScale(m_size);
                        }
    
    // override testitem
    virtual bool Hit(const Vector2f& i_pos);
    virtual void Render();
    virtual void  RenderNoTransform();
    
protected:
    
    float m_size;
    bool  m_isHit;
};

// -----------------------------------------------------------------------------

class TestItemSegment : public VisibleItem
{
public:
    TestItemSegment(const Vector2f& i_fromPos, const Vector2f& i_toPos)
    {
        SetPos(i_fromPos);
        m_toPos = i_toPos;
    }
    
    virtual bool Hit(const Vector2f& i_pos) {
                            return false;}
    
    virtual void Render();
private:
    Vector2f m_toPos;
};

// -----------------------------------------------------------------------------

class TestItemUIElement : public TestItemQuad
{
public:
    TestItemUIElement(const Vector2f& i_pos, const float i_size, VisibleItem* i_shownItem);
    ~TestItemUIElement();

    virtual bool Hit(const Vector2f& i_pos);
    virtual void Render();
    
private:
    VisibleItem* m_visibleItemShown;
};

// -----------------------------------------------------------------------------

class TestTextureQuad : public TestItemQuad
{
public:
    TestTextureQuad():TestItemQuad(Vector2f::Zero, 1.0f), m_textureReference(0) { }
    
    TestTextureQuad(const Vector2f& i_pos, float i_size, const CTexture* i_textureReference):TestItemQuad(i_pos, i_size), m_textureReference(i_textureReference) {
    }
    
    void SetTexture(const CTexture* i_textureReference) {
        m_textureReference = i_textureReference;
    }
    
    virtual void Render();
private:
    const CTexture* m_textureReference;
};

// -----------------------------------------------------------------------------

//class TestLabel : public VisibleItem
//{
//};    

